package com.tuanzi.loan.business.service.product.product.impl;

import com.tuanzi.loan.business.entity.product.product.LoanProductConsumeRecord;
import com.tuanzi.loan.business.repository.product.product.LoanProductConsumeRecordRepository;
import com.tuanzi.loan.business.service.product.product.LoanProductConsumeRecordService;
import com.tuanzi.loan.core.service.BaseService;
import com.tuanzi.loan.core.service.CommonServiceImpl;
import com.tuanzi.loan.core.vo.PageSearcher;
import com.tuanzi.loan.vo.request.product.product.LoanProductConsumeSearchRequest;
import com.tuanzi.loan.vo.response.product.product.LoanProductConsumeSearchResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Auther: hequnayu
 * @Date: 2019/7/15 16:22
 * @Description:
 */
@Service
public class LoanProductConsumeRecordServiceImpl extends CommonServiceImpl<LoanProductConsumeRecord,Long> implements LoanProductConsumeRecordService {

    @Autowired
    private LoanProductConsumeRecordRepository consumeRecordRepository;

    @Override
    public Page<LoanProductConsumeSearchResponse> list(PageSearcher<LoanProductConsumeSearchRequest> pageSearcher) {
        return consumeRecordRepository.list(pageSearcher.getSearchCondition(), pageSearcher.getPageable());
    }

    @Override
    public Double countConsumeMoneyByProdid(Long prdid) {
        return consumeRecordRepository.countConsumeMoneyByProdid(prdid);
    }

    @Override
    public List<LoanProductConsumeRecord> findAllByProid(Long prdid) {
        return consumeRecordRepository.findAllByProductId(prdid);
    }

    @Override
    protected JpaRepository<LoanProductConsumeRecord, Long> getRepository() {
        return consumeRecordRepository;
    }
}
